package com.aggregate.pay.pingan.bean;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.Map;

import com.aggregate.pay.pingan.jackson.converter.BooleanDeserialize;
import com.aggregate.pay.pingan.support.Dynamic;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

/**
 * 添加合同接口data参数对象，需要转换成JSON并加密赋给<code>CommonData</code>对象的<code>data</code>属性
 * @author Moyq5
 * @date 2017年6月24日
 */
public class ContractAddData implements Dynamic {

	/**
	 * 机构合同主键（系统有唯一性校验），建议使用合同表的主键ID，防止重复添加合同，必填，64。
	 */
	@JsonProperty("tra_id")
	private String contractId;
	
	/**
	 * 商户编号，必填，20
	 */
	@JsonProperty("mct_no")
	private String merchNo;
	
	/**
	 * 合同编号（系统有唯一性校验），必填，50
	 */
	private String code;
	
	/**
	 * 签购单名称，建议使用商户招牌名称，必填，50
	 */
	@JsonProperty("sign_name")
	private String signName;
	
	/**
	 * 合同签署日期（yyyy-mm-dd），必填，10
	 */
	@JsonProperty("sign_date")
	private String signDate;
	
	/**
	 * 合同签约人，必填，25
	 */
	@JsonProperty("sign_man")
	private String signMan;
	
	/**
	 * 合同生效日期（yyyy-mm-dd），必填，10
	 */
	@JsonProperty("sdate")
	private String startDate;
	
	/**
	 * 合同过期日期（yyyy-mm-dd），必填，10
	 */
	@JsonProperty("edate")
	private String endDate;
	
	/**
	 * 联系人，必填，25
	 */
	private String contact;
	
	/**
	 * 联系人电话，必填，25
	 */
	@JsonProperty("contact_tel")
	private String contactTel;
	
	/**
	 * 是否自动续签（1是，0否），必填，1
	 */
	@JsonProperty("auto_sign")
	@JsonDeserialize(converter = BooleanDeserialize.class)
	private Boolean autoSign;
	
	/**
	 * 合同照片【私密区】，必填，100
	 */
	private String pic1;
	
	/**
	 * 支付方式编号，必填，9
	 */
	@JsonProperty("pmt_id")
	private String paymentId;
	
	/**
	 * 支付方式行业分类编号，必填，9
	 */
	@JsonProperty("pmf_id")
	private String feeId;
	
	/**
	 * 签约扣率百分比（如：0.32），必填，4
	 */
	private BigDecimal fee;
	
	/**
	 * 封顶值（分为单位，无封顶填0），必填，9
	 */
	@JsonProperty("pmf_limit")
	private Integer limit;
	
	/**
	 * 合同照片【私密区】，25
	 */
	private String pic2;
	
	/**
	 * 1为自动提审，其他或者空为需提审，1
	 */
	@JsonProperty("mts")
	@JsonDeserialize(converter = BooleanDeserialize.class)
	private Boolean autoDeliver;
	
	private Map<String, Object> extras;

	@Override
	public Map<String, Object> toFinal() {
		Field[] fields = this.getClass().getDeclaredFields();
		for (Field field : fields) {
			if (!field.getName().equals("extras")) {
				try {
					field.setAccessible(true);
					String name = field.getName();
					JsonProperty jsonProperty = null;
					if (null != (jsonProperty = field.getAnnotation(JsonProperty.class))) {
						name = jsonProperty.value();
					}
					extras.put(name, field.get(this));
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
			}
		}
		return extras;
	}

	public String getContractId() {
		return contractId;
	}

	public void setContractId(String contractId) {
		this.contractId = contractId;
	}

	public String getMerchNo() {
		return merchNo;
	}

	public void setMerchNo(String merchNo) {
		this.merchNo = merchNo;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getSignName() {
		return signName;
	}

	public void setSignName(String signName) {
		this.signName = signName;
	}

	public String getSignDate() {
		return signDate;
	}

	public void setSignDate(String signDate) {
		this.signDate = signDate;
	}

	public String getSignMan() {
		return signMan;
	}

	public void setSignMan(String signMan) {
		this.signMan = signMan;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getContactTel() {
		return contactTel;
	}

	public void setContactTel(String contactTel) {
		this.contactTel = contactTel;
	}

	public Boolean getAutoSign() {
		return autoSign;
	}

	public void setAutoSign(Boolean autoSign) {
		this.autoSign = autoSign;
	}

	public String getPic1() {
		return pic1;
	}

	public void setPic1(String pic1) {
		this.pic1 = pic1;
	}

	public String getPaymentId() {
		return paymentId;
	}

	public void setPaymentId(String paymentId) {
		this.paymentId = paymentId;
	}

	public String getFeeId() {
		return feeId;
	}

	public void setFeeId(String feeId) {
		this.feeId = feeId;
	}

	public BigDecimal getFee() {
		return fee;
	}

	public void setFee(BigDecimal fee) {
		this.fee = fee;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}

	public String getPic2() {
		return pic2;
	}

	public void setPic2(String pic2) {
		this.pic2 = pic2;
	}

	public Boolean getAutoDeliver() {
		return autoDeliver;
	}

	public void setAutoDeliver(Boolean autoDeliver) {
		this.autoDeliver = autoDeliver;
	}

	public Map<String, Object> getExtras() {
		return extras;
	}

	public void setExtras(Map<String, Object> extras) {
		this.extras = extras;
	}

	@Override
	public String toString() {
		return "ContractAddData [contractId=" + contractId + ", merchNo=" + merchNo + ", code=" + code + ", signName="
				+ signName + ", signDate=" + signDate + ", signMan=" + signMan + ", startDate=" + startDate
				+ ", endDate=" + endDate + ", contact=" + contact + ", contactTel=" + contactTel + ", autoSign="
				+ autoSign + ", pic1=" + pic1 + ", paymentId=" + paymentId + ", feeId=" + feeId + ", fee=" + fee
				+ ", limit=" + limit + ", pic2=" + pic2 + ", autoDeliver=" + autoDeliver + ", extras=" + extras + "]";
	}

}
